package org.jeecg.modules.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.service.IHomeMenuService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import java.util.*;
/**
 * 首页
 * @Author: nc
 * @Date: 2023/2/3 14:26
 * @Description:
 */
@Api(tags="8.首页")
@RestController
@RequestMapping("/boot/homeController")
@Slf4j
public class HomeController {

    @Resource
    private IHomeMenuService homeMenuService;

    /**
     * 首页顶部菜单
     *
     * @param request
     * @return
     */
    @ApiOperation("首页顶部菜单")
    @RequestMapping(value = "/getHomeMenu", method = RequestMethod.POST)
    public Result<?> getHomeMenu(HttpServletRequest request) {
        List<Map<String, Object>> homeMenuList = homeMenuService.getHomeMenu("0");
        for(Map<String, Object> map : homeMenuList){
            List<Map<String, Object>> list = homeMenuService.getHomeMenu(map.get("id").toString());
            map.put("list",list);
        }
        return Result.ok(homeMenuList);
    }
}
